﻿using System;
using System.Text;
using System.Xml;
using System.Collections.Generic;
using System.IO;
using System.Net.Mail;
using System.Web;
using System.Net;
using System.Collections;

namespace MyspaceToolkit
{

    public class MyspaceClient
    {

        private string _apiHost;
        private string _consumerKey;
        private string _consumerSecret;
        private string _apiVersion;
        
        public string APIHostURL
        {
            get { return _apiHost; }
            set { _apiHost = value; }
        }

        public string ConsumerKey
        {
            get { return _consumerKey; }
            set { _consumerKey = value; }
        }

        public string ConsumerSecret
        {
            get { return _consumerSecret; }
            set { _consumerSecret = value; }
        }

        public string APIVersion
        {
            get { return _apiVersion; }
            set { _apiVersion = value; }
        }

        public MyspaceClient()
        {

        }

        public MyspaceClient(string APIHostUrl, string ConsumerKey, string ConsumerSecret, string APIVersion)
        {
            _apiHost = APIHostUrl;
            _consumerKey = ConsumerKey;
            _consumerSecret = ConsumerSecret;
            _apiVersion = APIVersion;
        }

        public GetUserProfileResponse GetUserProfile(GetUserProfileRequest userProfileRequest)
        {
            MySpaceProfile mp = new MySpaceProfile();
            GetUserProfileResponse responseObj = new GetUserProfileResponse();
            HttpPostUtility poster = new HttpPostUtility();
            HttpPostUtility.MyspaceRequest requestObj = new HttpPostUtility.MyspaceRequest();
            string returnStr = "";

            requestObj.APIversion = APIVersion;
            requestObj.AssetID = "";
            requestObj.BaseApiUrlHost = APIHostURL;
            requestObj.ConsumerKey = ConsumerKey;
            requestObj.ConsumerSecret = ConsumerSecret;
            requestObj.RequestMethod = HttpPostUtility.RequestMethod.GetProfile;
            requestObj.RequestMode = HttpPostUtility.RequestMode.QueryString;
            requestObj.ResponseType = userProfileRequest.ResponseFormat;
            requestObj.Token = "";
            requestObj.TokenSecret = "";
            requestObj.UserId = userProfileRequest.UserID;

            string resp = poster.MakeRequest(requestObj);
            responseObj.ResponseXMLorJSON = resp;
            responseObj.ResponseFormat = userProfileRequest.ResponseFormat;
            responseObj.MyspaceUserProfile.LoadXML(resp);

            return responseObj;
        }

        

    }

}